package hot100;

public class Solution98 {
    private Integer last = null;
    private boolean isValid = true;
    public boolean isValidBST(TreeNode root) {
        dfs(root);
        return isValid;
    }

    public void dfs(TreeNode root) {
        if (root == null) {
            return;
        }
        dfs(root.left);
        System.out.println(root.val);
        if (last != null && last >= root.val) {
            isValid = false;
            return;
        }
        last = root.val;
        dfs(root.right);
    }
}
